/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Mr. Tam
 */
@Entity
@Table(name = "Complaint_History")
@NamedQueries({
    @NamedQuery(name = "ComplaintHistory.findAll", query = "SELECT c FROM ComplaintHistory c"),
    @NamedQuery(name = "ComplaintHistory.findByComplaintHistoryId", query = "SELECT c FROM ComplaintHistory c WHERE c.complaintHistoryId = :complaintHistoryId"),
    @NamedQuery(name = "ComplaintHistory.findByPriorityId", query = "SELECT c FROM ComplaintHistory c WHERE c.priorityId = :priorityId"),
    @NamedQuery(name = "ComplaintHistory.findByLodgeDate", query = "SELECT c FROM ComplaintHistory c WHERE c.lodgeDate = :lodgeDate"),
    @NamedQuery(name = "ComplaintHistory.findByFixDate", query = "SELECT c FROM ComplaintHistory c WHERE c.fixDate = :fixDate"),
    @NamedQuery(name = "ComplaintHistory.findByClosingDate", query = "SELECT c FROM ComplaintHistory c WHERE c.closingDate = :closingDate")})
public class ComplaintHistory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue
    @Column(name = "complaint_history_id")
    private Integer complaintHistoryId;
    @Column(name = "priority_id")
    private Integer priorityId;
    @Column(name = "lodge_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lodgeDate;
    @Column(name = "fix_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fixDate;
    @Column(name = "closing_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date closingDate;
    @JoinColumn(name = "assigned_staff_id", referencedColumnName = "staff_id")
    @ManyToOne
    private Staff staff;
    @JoinColumn(name = "complaint_status_id", referencedColumnName = "complaint_status_id")
    @ManyToOne
    private ComplaintStatus complaintStatus;
    @JoinColumn(name = "complaint_id", referencedColumnName = "complaint_id")
    @ManyToOne
    private Complaint complaint;
    @OneToMany(mappedBy = "complaintHistory")
    private List<Solution> solutionList;

    public ComplaintHistory() {
    }

    public ComplaintHistory(Integer complaintHistoryId) {
        this.complaintHistoryId = complaintHistoryId;
    }

    public Integer getComplaintHistoryId() {
        return complaintHistoryId;
    }

    public void setComplaintHistoryId(Integer complaintHistoryId) {
        this.complaintHistoryId = complaintHistoryId;
    }

    public Integer getPriorityId() {
        return priorityId;
    }

    public void setPriorityId(Integer priorityId) {
        this.priorityId = priorityId;
    }

    public Date getLodgeDate() {
        return lodgeDate;
    }

    public void setLodgeDate(Date lodgeDate) {
        this.lodgeDate = lodgeDate;
    }

    public Date getFixDate() {
        return fixDate;
    }

    public void setFixDate(Date fixDate) {
        this.fixDate = fixDate;
    }

    public Date getClosingDate() {
        return closingDate;
    }

    public void setClosingDate(Date closingDate) {
        this.closingDate = closingDate;
    }

    public Staff getStaff() {
        return staff;
    }

    public void setStaff(Staff staff) {
        this.staff = staff;
    }

    public ComplaintStatus getComplaintStatus() {
        return complaintStatus;
    }

    public void setComplaintStatus(ComplaintStatus complaintStatus) {
        this.complaintStatus = complaintStatus;
    }

    public Complaint getComplaint() {
        return complaint;
    }

    public void setComplaint(Complaint complaint) {
        this.complaint = complaint;
    }

    public List<Solution> getSolutionList() {
        return solutionList;
    }

    public void setSolutionList(List<Solution> solutionList) {
        this.solutionList = solutionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (complaintHistoryId != null ? complaintHistoryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ComplaintHistory)) {
            return false;
        }
        ComplaintHistory other = (ComplaintHistory) object;
        if ((this.complaintHistoryId == null && other.complaintHistoryId != null) || (this.complaintHistoryId != null && !this.complaintHistoryId.equals(other.complaintHistoryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "data.ComplaintHistory[complaintHistoryId=" + complaintHistoryId + "]";
    }

}
